package main

import "fmt"

func main() {
	testAssert01()
}

func testAssert01() {
	var x interface{}
	var b float32 = 55.5
	x = b //空接口可以接收任意类型

	y := x.(float32)                 //断言~
	fmt.Printf("转换成功：%T %v\n", y, y) //float32 55.5

	//z0 := x.(int)
	//fmt.Printf("转换成功：%T %v\n", z0, z0) //panic: interface conversion: interface {} is float32, not int

	z1, ok := x.(int)

	if ok {
		fmt.Printf("转换成功：%T %v\n", z1, z1)
	} else {
		fmt.Printf("x：%T  无法转换为 z:%T\n", x, z1) //x：float32  无法转换为 z:int
	}
}
